package com.zh.elec.web.actions;

import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import com.zh.elec.model.Dealer;
import com.zh.elec.service.DealerService;
import com.zh.elec.web.actions.base.AbstractAction;

/**
 * 经销商表
 * @author scy
 *
 */
public class DealerAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1717279374983298990L;
	private DealerService dealerService;
	private Dealer dealer;
	private List<Dealer> list;
	/**
	 * 添加
	 * @return
	 */
	@Test
	public String save(){
		assert(dealer != null);
		assert(dealerService != null);
		Assert.assertEquals("dealerService.save()", dealerService.save(dealer));
		if(dealer != null){
			dealer = (Dealer)dealerService.save(dealer);
			return "success";
		}
		return "add";		
	}
	/**
	 * 修改
	 * @return
	 */
	public String update(){
		dealer = (Dealer)dealerService.update(dealer);
		return "success";
	}
	/**
	 * 删除
	 * @return
	 */
	public String del(){
		dealer = (Dealer)dealerService.del(dealer);
		return "success";
	}
	/**
	 * 查询
	 * @return
	 */
	public String find(){
		list = dealerService.findAll();
		return "success";
	}
	/**
	 * 根据name查询
	 * @return
	 */
	public String findByName(){
		String name = "";
		String value= "";
		List<Dealer> list = dealerService.findByName(name, value);
		System.out.println(list.size());
		return "success";
	}
	public Dealer getDealer() {
		return dealer;
	}
	public void setDealer(Dealer dealer) {
		this.dealer = dealer;
	}
	public void setDealerService(DealerService dealerService) {
		this.dealerService = dealerService;
	}
	public List<Dealer> getList() {
		return list;
	}
	public void setList(List<Dealer> list) {
		this.list = list;
	}	
	
}
